package com.project.core.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.project.core.base.BaseDAO;
import com.project.core.dao.IUsersDAO;
import com.project.core.model.Users;

@Repository
public class UsersDaoImpl extends BaseDAO implements IUsersDAO {
	
	private static Logger logger = Logger.getLogger(UsersDaoImpl.class);
	
	public UsersDaoImpl(){
		logger.info("UsersDaoImpl Execute ! ");
	}
	@Override
	public List<Users> queryUsersByAll() {
		logger.info("[Dao]queryUsersByAll Execute!");
		String sql = "SELECT "
				+ "u.users_id,"
				+ "u.users_name,"
				+ "u.users_ask,"
				+ "u.users_answer,"
				+ "u.users_email,"
				+ "u.users_adddate,"
				+ "u.users_sqx,"
				+ "u.users_qx,"
				+ "u.users_online,"
				+ "u.users_ip,"
				+ "u.users_logindate,"
				+ "u.users_logincount "
				+ "FROM tb_users u;";
		return queryForList(sql, new Object[]{}, Users.class);
	}
	
	@Override
	public Users queryUserById(String username) {
		String sql = "SELECT * FROM tb_users WHERE users_name = ?";
		Users user = queryForObject(sql, new Object[]{username }, Users.class);
		return user;
	}
	@Override
	public Users queryUserByIdPwd(String username, String pwd) {
		String sql = "";
		Users user = queryForObject(sql, new Object[]{username , pwd}, Users.class);
		return user;
	}
	
		
}
